<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>作业8 | Hugo Theme Dream</title>

    



<meta name="author" content="Lindixuan" />
<meta name="description" content="" />



<meta name="generator" content="Hugo 0.63.2" />

<link rel="canonical" href="https://lindixuan.gitee.io/post/%E4%BD%9C%E4%B8%9A8/" />


<meta property="og:title" content="作业8" />
<meta property="og:description" content="" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://lindixuan.gitee.io/post/%E4%BD%9C%E4%B8%9A8/" />
<meta property="article:published_time" content="2020-10-19T19:41:11+08:00" />
<meta property="article:modified_time" content="2020-10-19T19:41:11+08:00" />



<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="作业8"/>
<meta name="twitter:description" content=""/>


<link rel="stylesheet" href="/css/semantic.min.css" />
<link rel="stylesheet" href="/css/OverlayScrollbars.min.css" />
<link rel="stylesheet" href="/css/github-markdown.css" />
<link rel="stylesheet" href="/css/site.css" />


<style>
  a {
    color: seagreen !important;
  }
</style>



<style>
  .inverted a {
     color: darkseagreen !important;
  }
</style>


    


  
    <link rel="stylesheet" data-highlight href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/gruvbox-light.min.css" />
  



  </head>

  
  <body style="background: white;">
  
    
<nav class="ui secondary inverted menu dream-menu">

  <div class="item">
    <i class="large link bullseye icon dream-flip-toggle" title="Flip it!"></i>
  </div>
  <div class="item">
    <i class="large link home icon" title="Home" onclick="window.location.href = 'https:\/\/lindixuan.gitee.io'"></i>
  </div>
  <div class="item">
    <i class="large link icon theme-switch" onclick="themeSwitch()"></i>
  </div>
  
  <div class="item">
    <i class="large link search icon" onclick="toggleSearch()"></i>
  </div>
  
</nav>

    <div class="flip-container">
      <div class="flipper">
        <section class="front">
          <div class="dream-max-width">
            
<div class="ui centered relaxed grid dream-grid">
  <div class="sixteen wide mobile sixteen wide tablet twelve wide computer column markdown-body dream-single">

    <section class="ui top attached segment" id="dream-save-post-as-img">
      <header style="margin-top: 0 !important;">
        <h1 class="ui large header">
          作业8
          <div class="sub header">
            @
            
              Lindixuan
            
            · Monday, Oct 19, 2020
            · 3 minute read
            · Update at Oct 19, 2020
          </div>
        </h1>
      </header>

      
        <img class="ui image" style="margin-top: 2rem;" src="" />
      

      <article style="margin-top: 2rem;"><h1 id="第八次作业">第八次作业</h1>
<h2 id="1阅读-pseudocode-standard">1、阅读 Pseudocode Standard。</h2>
<h3 id="1用伪代码描述将十进制转换成16进制的方法">1）用伪代码描述将十进制转换成16进制的方法</h3>
<blockquote>
<p>input num_dec<br>
set num_hex=0<br>
if num_dec&lt;0  then<br>
set char=&rsquo;-&rsquo;<br>
endif<br>
set t=1<br>
repeat<br>
divide num_hex by 16 and get the quotient and remainder <br>
num_hex=quotient<br>
num_hex plus remainder*t<br>
t=t * 16<br>
until num_dec=0<br>
return num_hex</p>
</blockquote>
<h3 id="2c语言实现先用注释写好算法然后翻译">2）C语言实现（先用注释写好算法，然后翻译）</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-cpp" data-lang="cpp"><span style="color:#75715e">#</span><span style="color:#75715e">include</span><span style="color:#75715e">&lt;iostream&gt;</span><span style="color:#75715e">
</span><span style="color:#75715e"></span><span style="color:#75715e">#</span><span style="color:#75715e">include</span><span style="color:#75715e">&lt;string&gt;</span><span style="color:#75715e">
</span><span style="color:#75715e"></span><span style="color:#75715e">#</span><span style="color:#75715e">include</span><span style="color:#75715e">&lt;stack&gt;</span><span style="color:#75715e">
</span><span style="color:#75715e"></span><span style="color:#66d9ef">using</span> <span style="color:#66d9ef">namespace</span> std;

string <span style="color:#a6e22e">decToHex</span>(<span style="color:#66d9ef">int</span> num_dec)
{
	<span style="color:#66d9ef">int</span> t;
	string result;
	stack<span style="color:#f92672">&lt;</span><span style="color:#66d9ef">char</span><span style="color:#f92672">&gt;</span>sta;

	<span style="color:#75715e">//if num_dec&lt;0  then  
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//set char = &#39;-&#39;
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//endif
</span><span style="color:#75715e"></span>	<span style="color:#66d9ef">if</span> (num_dec <span style="color:#f92672">&lt;</span> <span style="color:#ae81ff">0</span>)         
	{
		num_dec <span style="color:#f92672">=</span> <span style="color:#f92672">-</span>num_dec;
		result <span style="color:#f92672">+</span><span style="color:#f92672">=</span> <span style="color:#e6db74"></span><span style="color:#e6db74">&#39;</span><span style="color:#e6db74">-</span><span style="color:#e6db74">&#39;</span>;
	}
	<span style="color:#75715e">/*set t=1  
</span><span style="color:#75715e">repeat  
</span><span style="color:#75715e">divide num_hex by 16 and get the quotient and remainder    
</span><span style="color:#75715e">num_hex=quotient  
</span><span style="color:#75715e">num_hex plus remainder*t  
</span><span style="color:#75715e">t=t * 16  
</span><span style="color:#75715e">until num_dec=0  */</span>
	<span style="color:#66d9ef">do</span>
	{
		t <span style="color:#f92672">=</span> num_dec <span style="color:#f92672">%</span> <span style="color:#ae81ff">16</span>;
		num_dec <span style="color:#f92672">/</span><span style="color:#f92672">=</span> <span style="color:#ae81ff">16</span>;
		<span style="color:#66d9ef">if</span> (t <span style="color:#f92672">&lt;</span> <span style="color:#ae81ff">10</span>)
		{
			sta.push((<span style="color:#e6db74"></span><span style="color:#e6db74">&#39;</span><span style="color:#e6db74">0</span><span style="color:#e6db74">&#39;</span> <span style="color:#f92672">+</span> t));
		}
		<span style="color:#66d9ef">else</span>
		{
			sta.push((<span style="color:#e6db74"></span><span style="color:#e6db74">&#39;</span><span style="color:#e6db74">A</span><span style="color:#e6db74">&#39;</span>) <span style="color:#f92672">+</span> t <span style="color:#f92672">-</span> <span style="color:#ae81ff">10</span>);
		}
	} <span style="color:#66d9ef">while</span> (num_dec <span style="color:#f92672">!</span><span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>);
	<span style="color:#66d9ef">while</span>(<span style="color:#f92672">!</span>sta.empty())
	{
		result <span style="color:#f92672">+</span><span style="color:#f92672">=</span> sta.top();
		sta.pop();
	}
	<span style="color:#75715e">//return num_hex
</span><span style="color:#75715e"></span>	result <span style="color:#f92672">+</span><span style="color:#f92672">=</span> <span style="color:#e6db74"></span><span style="color:#e6db74">&#39;</span><span style="color:#e6db74">H</span><span style="color:#e6db74">&#39;</span>;
	<span style="color:#66d9ef">return</span> result;
}

<span style="color:#66d9ef">int</span> <span style="color:#a6e22e">main</span>()
{
	<span style="color:#66d9ef">int</span> num[<span style="color:#ae81ff">6</span>] <span style="color:#f92672">=</span> { <span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">1</span>,<span style="color:#ae81ff">15</span>,<span style="color:#ae81ff">26</span>,<span style="color:#ae81ff">3265</span> };
	<span style="color:#66d9ef">for</span> (<span style="color:#66d9ef">int</span> i <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>; i <span style="color:#f92672">&lt;</span> <span style="color:#ae81ff">6</span>; i<span style="color:#f92672">+</span><span style="color:#f92672">+</span>)
	{
		cout <span style="color:#f92672">&lt;</span><span style="color:#f92672">&lt;</span> decToHex(num[i]) <span style="color:#f92672">&lt;</span><span style="color:#f92672">&lt;</span> endl;
	}
}
</code></pre></div><h3 id="3使用--1-0-1-15-263265-最为输入测试你的程序">3）使用 -1, 0, 1, 15, 26，3265 最为输入测试你的程序</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-cpp" data-lang="cpp">result:
<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>H
<span style="color:#ae81ff">0</span>H
<span style="color:#ae81ff">1</span>H
FH
<span style="color:#ae81ff">1</span>AH
CC1H
</code></pre></div><h2 id="2名词解释与对比">2、名词解释与对比</h2>
<h3 id="1top-down-design">1）Top-down design</h3>
<blockquote>
<p>Top-down and bottom-up are both strategies of information processing and knowledge ordering, used in a variety of fields including software, humanistic and scientific theories (see systemics), and management and organization. In practice, they can be seen as a style of thinking, teaching, or leadership.
A top-down approach (also known as stepwise design and stepwise refinement and in some cases used as a synonym of decomposition) is essentially the breaking down of a system to gain insight into its compositional sub-systems in a reverse engineering fashion. In a top-down approach an overview of the system is formulated, specifying, but not detailing, any first-level subsystems. Each subsystem is then refined in yet greater detail, sometimes in many additional subsystem levels, until the entire specification is reduced to base elements. A top-down model is often specified with the assistance of &ldquo;black boxes&rdquo;, which makes it easier to manipulate. However, black boxes may fail to clarify elementary mechanisms or be detailed enough to realistically validate the model. Top down approach starts with the big picture. It breaks down from there into smaller segments.</p>
</blockquote>
<h3 id="2-work-breakdown-structure-wbs">2） Work breakdown structure (WBS)</h3>
<blockquote>
<p>A work-breakdown structure (WBS) in project management and systems engineering, is a deliverable-oriented breakdown of a project into smaller components. A work breakdown structure is a key project deliverable that organizes the team&rsquo;s work into manageable sections. The Project Management Body of Knowledge (PMBOK 5) defines the work-breakdown structure as a &ldquo;hierarchical decomposition of the total scope of work to be carried out by the project team to accomplish the project objectives and create the required deliverables.&rdquo;</p>
</blockquote>
<h3 id="3简述管理学-wbs-与-信息学top-down设计-的异同">3）简述管理学 WBS 与 信息学Top-down设计 的异同</h3>
<blockquote>
<p>Top-down 是从上往下拆分，而WBS是按照类型拆分<br>
Top-down和WBS都可以将大任务拆分成很多小任务</p>
</blockquote>
<h2 id="3洗衣机算法">3.洗衣机算法</h2>
<p>仔细观察您洗衣机的运作过程，运用Top-down设计方法和Pseudocode 描述洗衣机控制程序。假设洗衣机可执行的基本操作如下：<br>
water_in_switch(open_close) // open 打开上水开关，close关闭<br>
water_out_switch(open_close) // open 打开排水开关，close关闭<br>
get_water_volume() //返回洗衣机内部水的高度<br>
motor_run(direction) // 电机转动。left左转，right右转，stop停<br>
time_counter() // 返回当前时间计数，以秒为单位<br>
halt(returncode) //停机，success 成功 failure 失败</p>
<h3 id="1请使用伪代码分解正常洗衣程序的大步骤包括注水浸泡等">1）请使用伪代码分解“正常洗衣”程序的大步骤。包括注水、浸泡等</h3>
<blockquote>
<p><strong>1.Press the start button to select the water level and select the time</strong>
<strong>2.Fill to specified water level</strong><br>
<strong>3.Soak until the specified time</strong><br>
<strong>4.Rinse and rotate the motor. Turn left 3 times and  right 3 times per cycle</strong><br>
<strong>5.drainage</strong><br>
<strong>6.Dehydration, motor rotation</strong><br>
<strong>7.Finished</strong></p>
</blockquote>
<h3 id="2进一步用基本操作控制语句ifforwhile等变量与表达式写出每个步骤的伪代码">2）进一步用基本操作、控制语句（IF、FOR、WHILE等）、变量与表达式，写出每个步骤的伪代码</h3>
<pre><code>READ waterLine，timeLine1, timeLine2
REPEAT
water_in_switch(open)
UNTIL get_water_volume==waterLine
water_in_switch(close)
REPEAT
浸泡
UNTIL time_counter()==timeLine1
SET nowTime = time_counter()
REPEAT
SET tempTime1 = time_counter()
REPEAT
motor_run(left)
UNTIL time_counter()-tempTime1==3 SET tempTime2 = time_counter()
REPEAT
motor_run(right)
UNTIL time_counter()-tempTime2==3
motor_run(stop)
UNTIL time_counter()-nowTime==timeLine2
REPEAT
water_out_switch(open)
UNTIL get_water_volume==0
water_out_switch(close)
halt(0)
</code></pre><h3 id="3根据你的实践请分析正常洗衣与快速洗衣在用户目标和程序上的异同--你认为是否存在改进创新空间简单说明你的改进意见">3）根据你的实践，请分析“正常洗衣”与“快速洗衣”在用户目标和程序上的异同。  你认为是否存在改进（创新）空间，简单说明你的改进意见？</h3>
<blockquote>
<p>正常洗衣有浸泡，快速洗衣没有浸泡。可以加自动烘干功能。</p>
</blockquote>
<h3 id="4通过步骤3提取一些共性功能模块函数简化正常洗衣程序使程序变得更利于人类理解和修改维护例如waittime-等待指定的时间注水volumetimeout-在指定时间内完成注水否则停机排水timeout-等子程序">4）通过步骤3），提取一些共性功能模块（函数），简化“正常洗衣”程序，使程序变得更利于人类理解和修改维护。例如：wait(time) //等待指定的时间；注水(volume,timeout) //在指定时间内完成注水，否则停机；排水(timeout)。 等子程序</h3>
<pre><code>FUNCTION 注水(volume,timeout)
SET nowTime=timecounter();
REPEAT
IF timecounter()-newTime==timeout THEN
halt(1)
ENDIF
water_in_switch(open)
UNTIL get_water_volume==volume
water_in_switch(close)
waterinswitch(close)
ENDFUNCTION

FUNCTION 排水(timeout)
SET nowTine=timecounter();
REPEAT
IF timecounter()-newTime==timeout THEN
halt(1)
ENDIF
water_out_switch(open)
UNTIL get_water_volume==0
water_out_switch(close)
ENDFUNCTION
</code></pre></article>
    </section>

    <footer class="ui attached segment dream-tags">
      
          <a class="ui label">No Tags</a>
      
      <div
        class="ui label"
        style="float: right; cursor: pointer;"
        onclick="savePostAsImg()">
        <i class="save icon"></i>Save as image
      </div>
    </footer>

    

    
    
    

  </div>
  <div class="sixteen wide mobile sixteen wide tablet four wide computer column">
    <article class="dream-header">
  <section class="ui top attached center aligned segment">
    <div class="ui small circular image">
      
        <img src="/img/sleep.jpg">
      
    </div>

    
    <h1 class="ui medium header">Lindixuan&#39;s blog<div class="sub header" style="margin-top: 0.5rem;">好耶！</div>
    </h1>
    

    <div class="ui horizontal list">
      
      <a class="item" href="/tags">
        <i class="tags icon" title="All Tags"></i>
      </a>
      <a class="item" href="/categories">
        <i class="th list icon" title="All Categories"></i>
      </a>
    </div>
  </section>

  

  

  <section class="ui attached segment header-socials">
    <nav class="ui secondary menu dream-menu dream-socials">
  
  
    <div class="item">
      <a href="mailto:1228210482@qq.com">
        <i class=" mail icon" title="Email"></i>
      </a>
    </div>
  

  

  

  

  

  

  

  
</nav>

  </section>

  <section class="ui bottom attached center aligned segment">
    
      <p>© 2020 - 2021 Hugo Theme Dream</p>
    

    <p>Powered by <a href="https://gohugo.io/" target="_blank">Hugo</a> with theme <a href="https://github.com/g1eny0ung/hugo-theme-dream" target="_blank">Dream</a>.</p>

    
  </section>
</article>

  </div>
</div>

          </div>
        </section>
        <section class="back">
          <div class="dream-max-width">
            <div class="ui centered relaxed grid dream-grid dream-back">
  
  
  

  <section class="sixteen wide mobile eight wide tablet four wide computer column dream-column">
    <article>
      <div class="ui top attached segment">
        <h3 class="ui header">Social Links</h3>
      </div>
      <div class="ui bottom attached segment">
        <nav class="ui secondary menu dream-menu dream-socials">
  
  
    <div class="item">
      <a href="mailto:1228210482@qq.com">
        <i class="large mail icon" title="Email"></i>
      </a>
    </div>
  

  

  

  

  

  

  

  
</nav>

      </div>
    </article>
  </section>

  <section class="sixteen wide mobile eight wide tablet four wide computer column dream-column">
    
  </section>

  
    
  
</div>

          </div>
        </section>
      </div>
    </div>

    <script>
  window.darkNav =  true 
</script>
<script src="/js/jquery.min.js"></script>
<script src="/js/semantic.min.js"></script>
<script src="/js/jquery.overlayScrollbars.min.js"></script>
<script src="/js/header.js"></script>
<script src="/js/main.js"></script>
<script src="/js/theme.js"></script>

    
<script src="/js/html2canvas.min.js"></script>
<script src="/js/post.js"></script>


  <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js"></script>

  
    
      <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/languages/ocaml.min.js"></script>
     
  

  <script>
  hljs.initHighlightingOnLoad()
  setHighlightTheme()

  function setHighlightTheme() {
    var isDark = localStore.getItem('hugo-theme-dream-is-dark')
    var lightTheme = "gruvbox-light"
    var darkTheme = "gruvbox-dark"
    var theme = isDark ? darkTheme : lightTheme

    $('link[data-highlight]').attr('href', 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/' + theme + '.min.css')
    $('pre').css('background', isDark ? '#333' : '')
  }
</script>





    
      <div class="ui inverted segment" id="dream-search">
  <div class="ui search">
    <div class="ui transparent input">
      <input class="prompt" type="text" placeholder="Search" />
    </div>
    <div class="results"></div>
  </div>
</div>
<script>
  $(document).ready(function () {
    $.getJSON('https:\/\/lindixuan.gitee.io/index.json', function (data) {
      $('.ui.search').search({
        source: data,
        searchFields: ['title'],
        showNoResults: true,
      })
    })
  })
</script>
<script src="/js/search.js"></script>

    

    
  </body>
</html>
